//
//  OilCardCell.m
//  NtoccDriverNew
//
//  Created by apple on 10/30/20.
//  Copyright © 2020 GCY. All rights reserved.
//

#import "OilCardCell.h"

@interface OilCardCell ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIView *branchBGView;
@property (weak, nonatomic) IBOutlet UIView *qrBGView;
@property (weak, nonatomic) IBOutlet UILabel *branchNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *oilCardLabel;
@property (weak, nonatomic) IBOutlet UIImageView *qrImageView;
@property (weak, nonatomic) IBOutlet UIImageView *branchIcon;
@property (weak, nonatomic) IBOutlet UIImageView *oilcardIcon;
@property (weak, nonatomic) IBOutlet UIImageView *arrowImageView;

@end

@implementation OilCardCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = [UIColor cy_colorWithHexString:@"#1867E0"];
    cut(_bgView, 10);
}

- (void)setModel:(OilCardModel *)model {
    _model = model;
    _branchNameLabel.text = model.branchName;
    _branchNameLabel.adjustsFontSizeToFitWidth = YES;
//    _oilCardLabel.text = [NSString stringWithFormat:@"%f", model.oilCard];
    _oilCardLabel.text = CJStringWithFormat(@"%.2f", model.oilCard);
    if (model.isSelected) {
        _branchBGView.backgroundColor = [UIColor cy_colorWithHexString:@"#F4F8FD"];
        _branchNameLabel.textColor = [UIColor blackColor];
        _oilCardLabel.textColor = [UIColor blackColor];
        _branchIcon.image = image(@"gcy_icon_branch");
        _oilcardIcon.image = image(@"gcy_icon_oilcard");
        _arrowImageView.image = image(@"gcy_icon_oil_arrow_gray");
        [_qrImageView sd_setImageWithURL:[NSURL URLWithString:model.qrImageURLStr] placeholderImage:image(@"gcy_icon_plaholder")];
        DebugLog(@"%f------------%f", _qrImageView.image.size.width, _qrImageView.image.size.height);
    } else {
        _branchBGView.backgroundColor = [UIColor cy_colorWithHexString:@"#3da3f1"];
        _branchNameLabel.textColor = [UIColor whiteColor];
        _oilCardLabel.textColor = [UIColor whiteColor];
        _branchIcon.image = image(@"gcy_icon_branch_white");
        _oilcardIcon.image = image(@"gcy_icon_oilcard_white");
        _arrowImageView.image = image(@"gcy_icon_oil_arrow_white");
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
